//
//  LDBossFinderResumeHightLightCell.swift
//  DingDongZP
//
//  Created by 三秒文化 on 16/6/8.
//  Copyright © 2016年 iyhjiang.com. All rights reserved.
//


import UIKit
import Neon

class LDBossFinderResumeHightLightCell: LDBaseRecFinderCell {
    
    
    var myLight:UILabel?
    var divideline:UIView?
    var myDesc:UILabel?
//    var backMeritImgView:UIImageView?
    
    let SameLabTag = 333
    
    var model = LDBossFinderResumeHightLightCellModel() {
        
        didSet{
            updateFrame()
        }
    }
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style , reuseIdentifier: reuseIdentifier)
        setDefalutContent()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setDefalutContent() {
        
        self.frame = LDFrame.ScreenBounds
        myLight = UILabel.setHeadTitleLab("我的亮点")
        
        divideline = UIImageView.setupDivideLine_H(LDFrame.ScreenWidth - Margin_V * 10)
        myDesc = UILabel.setDetailsLab("", fontSize: 14, titleColor: LDFontColor.DeepGray,Alignment: nil)
        
        gapView.addSubview(myLight!)
        gapView.addSubview(divideline!)
        gapView.addSubview(myDesc!)
        
//        backMeritImgView = UIImageView.setDefaultGoundImg("我的亮点", radius: nil)
//        addSubview(backMeritImgView!)
//        backMeritImgView?.anchorInCorner(.TopRight, xPad: Margin_V*4, yPad: Margin_V*2.5, width: 22, height: 22)
        
        //neon简单布局
        //左边竖线
        let VHeading = UIView.init()
        VHeading.backgroundColor = LDGolbalColor.GreenAssist
        gapView.addSubview(VHeading)
        
        VHeading.anchorInCorner(.TopLeft, xPad: Margin_V*3, yPad: Margin_V*4, width: 2.5, height: 20)
        myLight?.align(.ToTheRightCentered, relativeTo: VHeading, padding: Margin_V*2, width: 120, height: 25)
        divideline!.align(.UnderMatchingLeft, relativeTo: VHeading, padding: LDMargin_V*2, width: LDFrame.ScreenWidth - Margin_V * 10, height: 1)
        
    }
    //得到models后刷新lab内容
    func updateFrame(){
        
        myDesc?.align(.UnderMatchingLeft, relativeTo: divideline!, padding: LDMargin_V*3, width: LDFrame.ScreenWidth -  LDMargin_V*10, height: model.cellheight_desc )

        if model.mystrengthstext.characters.count > 0 {
            
          myDesc?.attributedText = String.getAttrFormString(lineH: 8, text: model.mystrengthstext, font: LDFont.Font13)
            
        } else {
            myDesc?.text = "我的优势文本还未录入"
        }
        
        let Y = (CGRectGetMaxY((myDesc?.frame)!))
        
        var labstitleArr = [String]()
        labstitleArr = model.highlights ?? [String]()

       UILabel.creatLabsFromArrTags(labstitleArr, labsTag: SameLabTag, labH: 20, font: LDFont.Font13, toView: gapView, originX: 13, originY: Y, marginX: 13, marginY: 13)
    }
    
    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
    }
    
}

class LDBossFinderResumeHightLightCellModel: NSObject {
    
    let SameLabTag = 333
    var height:CGFloat = LDCellFrame.Margin_V*2 + LDMargin_V*3*3 + 25
    

    var cellheight_desc:CGFloat = 0 {
        didSet{
            height = height + cellheight_desc
        }
    }
    var cellheight_labs:CGFloat = 0 {
        didSet{
            height = height + cellheight_labs
        }
    }
    
    
    var mystrengthstext = "" {// 我的优势文本
        didSet{
            
            let size = CGSizeMake(LDFrame.ScreenWidth - LDMargin_V * 8, CGFloat.max)
//            let height = UILabel.getLabRectFromString(LDFont.Font14, size: size, str: mystrengthstext)
            
            let height = String.getHeightFormAttr(8, title: mystrengthstext, size: size, font: LDFont.Font13)
            cellheight_desc = height
        }
    }
    
    var highlightscount = ""     // 我的亮点标签数目
       
    var highlights = [String]() {// 我的亮点标签数组
    
        didSet{
            
            cellheight_labs = UILabel.getLabsAllHight(highlights, labH: 20, font: LDFont.Font13, originX: 13, marginX: 13, marginY: 13)
        }
    }
}
